package test;

//字符串替换
public class topic03 {
    public String formatString(String A, int n, char[] arg, int m) {
        // write code here
        int i = 0;
        while (A.indexOf("%s") >= 0) //返回字符串中第一次出现这个字符的索引,如果找不到,则返回-1
             {
            A = A.replaceFirst("%s", String.valueOf(arg[i]));//字符串替换
            i++;
        }
        while (i < m) {
            A += arg[i];
            i++;
        }
        return A;
    }
}
